/**
 
 */

#ifndef __MyIni_H_
#define __MyIni_H_
#include <string>
#include <map>
#include <vector>

struct IniPrivateData
{
    std::string section;
    std::map<std::string,std::string> keyData; 
};

typedef std::vector<IniPrivateData> IniData; // [ [sec]{key=val, key=val...} , ,,, ]

class MyIni
{

public:
    MyIni();
    MyIni(const std::string iniFile);
    ~MyIni();

    bool IsExist(); 
    int Read(const std::string section,const std::string key,const int defaultval);
    std::string Read(const std::string section,const std::string key,const std::string defaultval);

    void WriteInt(const std::string section,const std::string key,const int val);
    void WriteString(const std::string section,const std::string key,const std::string val); 

    bool Save();
    bool SaveAs(const std::string otherIniFile);
   

private:
   IniData data; // [ [sec]{key=val, key=val...} , ,,, ]
   FILE *fd;
   std::string iniFile;
};


void test_my_ini();




#endif
